﻿<navigation:Page x:Class="Mal.Balades.Admin.Views.Feeds" 
           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
           xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
           xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
           xmlns:viewmodels="clr-namespace:Mal.Balades.Admin.ViewModels.FeedViewModels" 
           xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"
           xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls" 
           mc:Ignorable="d"
           xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
           d:DesignWidth="640" d:DesignHeight="480"
           Title="Feeds Page">
    <navigation:Page.DataContext>
        <viewmodels:FeedsViewModel />
    </navigation:Page.DataContext>
    <Grid x:Name="LayoutRoot">

        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition Height="Auto"/>
            <RowDefinition />
            <RowDefinition Height="50" />
        </Grid.RowDefinitions>

        <data:DataGrid x:Name="feeds" IsEnabled="{Binding IsEnabled}" Margin="0,0,0,0" AutoGenerateColumns="false" 
             ItemsSource="{Binding Feeds, Mode=TwoWay}" Grid.Row="0">
            <data:DataGrid.Columns>
                <data:DataGridTemplateColumn >
                    <data:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Grid>
                                <CheckBox IsChecked="{Binding IsSelected, Mode=TwoWay}"/>
                            </Grid>
                        </DataTemplate>
                    </data:DataGridTemplateColumn.CellTemplate>
                </data:DataGridTemplateColumn>
                
                <data:DataGridTemplateColumn Header="Name">
                    <data:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Grid>
                                <TextBlock Text="{Binding Name}"/>
                            </Grid>
                        </DataTemplate>
                    </data:DataGridTemplateColumn.CellTemplate>
                </data:DataGridTemplateColumn>

                <data:DataGridTemplateColumn Header="Url">
                    <data:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Grid>
                                <HyperlinkButton MaxWidth="300" TargetName="_blank"
                                    NavigateUri="{Binding Url}" Content="{Binding Url}" />
                            </Grid>
                        </DataTemplate>
                    </data:DataGridTemplateColumn.CellTemplate>
                </data:DataGridTemplateColumn>

                <data:DataGridTemplateColumn Header="Latitude">
                    <data:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Grid>
                                <TextBlock Text="{Binding Latitude}"/>
                            </Grid>
                        </DataTemplate>
                    </data:DataGridTemplateColumn.CellTemplate>
                </data:DataGridTemplateColumn>

                <data:DataGridTemplateColumn Header="Longitude">
                    <data:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Grid>
                                <TextBlock Text="{Binding Longitude}"/>
                            </Grid>
                        </DataTemplate>
                    </data:DataGridTemplateColumn.CellTemplate>
                </data:DataGridTemplateColumn>

                <data:DataGridTemplateColumn Header="Items">
                    <data:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Grid>
                                <TextBlock Text="{Binding Items}"/>
                            </Grid>
                        </DataTemplate>
                    </data:DataGridTemplateColumn.CellTemplate>
                </data:DataGridTemplateColumn>

                <data:DataGridTemplateColumn Header="LastUpdate">
                    <data:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Grid>
                                <TextBlock Text="{Binding LastUpdate}"/>
                            </Grid>
                        </DataTemplate>
                    </data:DataGridTemplateColumn.CellTemplate>
                </data:DataGridTemplateColumn>

                <data:DataGridTemplateColumn Header="Status">
                    <data:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Grid>
                                <TextBlock Text="{Binding Status}"/>
                            </Grid>
                        </DataTemplate>
                    </data:DataGridTemplateColumn.CellTemplate>
                </data:DataGridTemplateColumn>
                
                <!-- <data:DataGridTemplateColumn Header="">
                    <data:DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Grid>
                                <Button Command="{Binding EditCommand}" 
                                        Content="Modifier" CommandParameter="{Binding}" />
                            </Grid>
                        </DataTemplate>
                    </data:DataGridTemplateColumn.CellTemplate>
                </data:DataGridTemplateColumn>-->
            </data:DataGrid.Columns>
        </data:DataGrid>

        <CheckBox IsChecked="{Binding IsAllSelected, Mode=TwoWay}" 
                  IsEnabled="{Binding IsEnabled}"
                  Margin="4" />
        
        <controls:GridSplitter Grid.Row="1" Height="10" HorizontalAlignment="Stretch" />
        
        <Grid Grid.Row="2" >
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" MinWidth="200" />
                <ColumnDefinition />
            </Grid.ColumnDefinitions>
            
            <Grid.RowDefinitions>
                <RowDefinition Height="auto" />
                <RowDefinition Height="auto" />
                <RowDefinition Height="auto"/>
                <RowDefinition Height="auto"/>
            </Grid.RowDefinitions>
             
            <TextBlock Text="Name : " Grid.Row="0" Grid.Column="0" />
            <TextBox Grid.Row="0" Grid.Column="1"   
                     KeyUp="OnTextBoxKeyUp"
                Text="{Binding SelectedItem.Name, ElementName=feeds, Mode=TwoWay}" />

            <TextBlock Text="Url : " Grid.Row="1" Grid.Column="0" />
            <TextBox Grid.Row="1" Grid.Column="1"   
                     KeyUp="OnTextBoxKeyUp"
                Text="{Binding SelectedItem.Url, ElementName=feeds, Mode=TwoWay}" />

            <TextBlock Text="Latitude : " Grid.Row="2" Grid.Column="0" />
            <TextBox Grid.Row="2" Grid.Column="1"   
                     KeyUp="OnTextBoxKeyUp"
                Text="{Binding SelectedItem.Latitude, ElementName=feeds, Mode=TwoWay}" />

            <TextBlock Text="Longitude : " Grid.Row="3" Grid.Column="0" />
            <TextBox Grid.Row="3" Grid.Column="1"   
                     KeyUp="OnTextBoxKeyUp"
                Text="{Binding SelectedItem.Longitude, ElementName=feeds, Mode=TwoWay}" />
        </Grid>
        
        <StackPanel Orientation="Horizontal" Grid.Row="3">
            <Button Command="{Binding UpdateFeedItemsCommand}" 
                    IsEnabled="{Binding IsUpdateFeedItemsEnabled}" 
                    Content="Update feed items" />
        </StackPanel>
    </Grid>
</navigation:Page>
